//
//  OrderBarView.swift
//  TianXiaoQi
//
//  Created by Rookie_YX on 16/6/21.
//  Copyright © 2016年 YX_Rookie. All rights reserved.
//

import UIKit

class OrderBarView: UIView {
    
    var priceL = UILabel()
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        setupUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    private func setupUI(){
        
        // 购物车按钮
        addSubview(shopCarBtn)
        // 价钱
        addSubview(priceLabel)
        // 加入购物车按钮
        addSubview(appendShopCarButton)
        // 购买按钮
        addSubview(buyButton)
        
        /// 布局
        shopCarBtn.snp_makeConstraints { (make) in
            make.left.equalTo(self)
            make.centerY.equalTo(self)
            make.height.equalTo(44)
            make.width.equalTo(44)
        }
        
        priceLabel.snp_makeConstraints { (make) in
            make.left.equalTo(shopCarBtn.snp_right).offset(3)
            make.centerY.equalTo(shopCarBtn)
            make.height.equalTo(self)
            make.width.equalTo(appendShopCarButton)
        }
        
        appendShopCarButton.snp_makeConstraints { (make) in
            make.left.equalTo(priceLabel.snp_right)
            make.top.bottom.equalTo(self)
            make.width.equalTo(buyButton)
        }
        
        buyButton.snp_makeConstraints { (make) in
            make.left.equalTo(appendShopCarButton.snp_right)
            make.right.equalTo(self)
            make.top.bottom.equalTo(self)
            make.width.equalTo(appendShopCarButton)
        }
    }
    
    // MARK:- 懒加载
    private lazy var shopCarBtn:UIButton = {
        let btn = UIButton()
        btn.setBackgroundImage(UIImage(named:"f_p_cart_19x19"), forState: UIControlState.Normal)
        btn.layer.borderColor = UIColor.lightGrayColor().CGColor
        btn.layer.borderWidth = 0.5
        return btn
    }()
    
    private lazy var priceLabel:UILabel = {
        let lab = UILabel()
        lab.text = "20/元"
        lab.textAlignment = .Center
        lab.textColor = UIColor.blackColor()
        lab.font = UIFont.systemFontOfSize(15)
        lab.backgroundColor = UIColor.lightGrayColor()
        lab.layer.borderColor = UIColor.lightGrayColor().CGColor
        lab.layer.borderWidth = 0.5
        self.priceL = lab
        return lab
    }()
    
    private lazy var appendShopCarButton:UIButton = {
        let btn = UIButton()
        btn.setTitle(" 加入购物车 ", forState: .Normal)
        btn.setTitleColor(UIColor.whiteColor(), forState: .Normal)
        btn.backgroundColor = UIColor.grayColor()
        return btn
    }()
    
    private lazy var buyButton:UIButton = {
        let btn = UIButton()
        btn.setTitle(" 购买 ", forState: .Normal)
        btn.setTitleColor(UIColor.whiteColor(), forState: .Normal)
        btn.backgroundColor = UIColor.blackColor()
        return btn
    }()
    
}
